var form = layui.form;
var layer = layui.layer;
var $ = layui.jquery;
var element = layui.element;
var laytpl = layui.laytpl;
var laypage = layui.laypage;
var upload = layui.upload;
var laydate = layui.laydate;
var slider = layui.slider;

//绑定提交功能
function formOnSubmit(event, type, url, func) {
	form.on("submit(" + event + ")", function(data) {
		ajax(url, type, data.field, func)
	});
}
//ajax 
function ajax(url, type, field, func) {
	$.ajax({
		url: base.app + url,
		type: "post",
		data: field,
		dataType: type,
		success: func
	});
}

function goUrl(url) {
	location.href = base.app + url;
}

function frameClose() {
	var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
	parent.layer.close(index); //再执行关闭
}

function uploadImage(id, bindAction, url, choose, func) {
	upload.render({
		elem: '#' + id //绑定元素
		, url: base.app + url //上传接口
		, auto: false // 关闭自动上传
		, bindAction: '#' + bindAction //指向一个按钮触发上传
		, choose: choose
		, done: func
	})
}

// 		打开功能
function layerOpen(title, url, width, height, end) {
	layer.open({
		type: 2,
		content: base.app + url,
		area: [width, height],
		fixed: false,
		maxmin: true,
		shade: 0.3,
		end: end,
		title: title,
		moveOut: true
	})
}

